import { Component, OnInit, ViewChild, ViewEncapsulation } from '@angular/core';
import { InfiniteLoaderComponent, InfiniteLoaderConfig } from 'ngx-weui/infiniteloader';
import { ActivatedRoute, Router } from '@angular/router';
import { StorageService } from 'src/app/core/sotrage/storage.service';
import { ApiService } from 'src/app/core/api';

@Component({
  templateUrl: './index.component.html',
  styleUrls: ['./index.component.less'],
  encapsulation: ViewEncapsulation.None,
})
export class MhListComponent implements OnInit {
  @ViewChild(InfiniteLoaderComponent, { static: true }) il;
  showDailog=true;
  isShowRadio=true;
  radio=[{ id: 1, name: '余额(699 Jpoint)' }];
  radioType;
  restartBtn = false;
  pageData = {
    pageNo: 1,
    pages: 1,
    "cartoonId": '', //# 必填 漫画编号
    "chapterName": ""
  }
  list = []
  constructor(
    private api: ApiService,
    private sto: StorageService,
    private activedRoute: ActivatedRoute,
    private router: Router
  ) {
  }
  onLoadMore(comp: InfiniteLoaderComponent) {
    this.restartBtn = false;
    comp.resolveLoading();
    if (this.pageData['pageNo'] < this.pageData['pages']) {
      this.pageData['pageNo']++;
      this.getList();
    }
  }
  infiniteLoaderConfig: InfiniteLoaderConfig = {
    height: '60vh'
  };
  ngOnInit() {
    this.radioType = this.radio[0];
    this.pageData.cartoonId = this.activedRoute.snapshot.queryParams.cartoonId;
    this.getList();
  };

  getList() {
    for (let i = 0; i < 10; i++) {
      this.list.push({
        "id": 1,
        "chapterName": "寻找七龙珠下",
        "levelStar": 1.1,
        "briefInfo": "创建漫画七龙珠",
        "price": 13.00000000,
        "isTrade": "Y",//#是否收费 Y是，N否
        "thumbnail": "http://127.0.0.1:8213\\cartoonChapter\\2020-03-06\\13\\0.jpg",
        "createTime": "2020-03-10 14:56:20"
      })

    }
    this.api.post('漫画章节列表', this.pageData).then((e: any) => {
    });
  }
  back(){
    history.back();
  }
}
